<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Eigen: Fixed-size vectorizable Eigen objects</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="eigen_navtree_hacks.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen</a>
   &#160;<span id="projectnumber">3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)</span>
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__TopicFixedSizeVectorizable.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Fixed-size vectorizable Eigen objects<div class="ingroups"><a class="el" href="group__DenseMatrixManipulation__chapter.html">Dense matrix and array manipulation</a> &raquo; <a class="el" href="group__DenseMatrixManipulation__Alignement.html">Alignment issues</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<p>The goal of this page is to explain what we mean by "fixed-size vectorizable".</p>
<h1><a class="anchor" id="FixedSizeVectorizable_summary"></a>
Executive Summary</h1>
<p>An <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> object is called "fixed-size vectorizable" if it has fixed size and that size is a multiple of 16 bytes.</p>
<p>Examples include: </p><ul>
<li><a class="el" href="group__matrixtypedefs.html#ga6c206cbf6f8f3b74bc63ecd362fc2ad6" title="2×1 vector of type double.">Eigen::Vector2d</a> </li>
<li><a class="el" href="group__matrixtypedefs.html#ga9b2fcb53776a2829871f8a49009bef0b" title="4×1 vector of type double.">Eigen::Vector4d</a> </li>
<li><a class="el" href="group__matrixtypedefs.html#gae6a8e578d2848cc75f573c15a73bd9b4" title="4×1 vector of type float.">Eigen::Vector4f</a> </li>
<li><a class="el" href="group__matrixtypedefs.html#ga3b934095f8a2834e6cc27267427239d3" title="2×2 matrix of type double.">Eigen::Matrix2d</a> </li>
<li><a class="el" href="group__matrixtypedefs.html#ga36b8989b6aa63020139fc36bae6979e0" title="2×2 matrix of type float.">Eigen::Matrix2f</a> </li>
<li><a class="el" href="group__matrixtypedefs.html#ga31c5fac458c04196a36b36b5e51127ff" title="4×4 matrix of type double.">Eigen::Matrix4d</a> </li>
<li><a class="el" href="group__matrixtypedefs.html#ga3a5de8dfef28d29aed525611e15a37e3" title="4×4 matrix of type float.">Eigen::Matrix4f</a> </li>
<li>Eigen::Affine3d </li>
<li>Eigen::Affine3f </li>
<li><a class="el" href="group__Geometry__Module.html#ga5daab8e66aa480465000308455578830">Eigen::Quaterniond</a> </li>
<li><a class="el" href="group__Geometry__Module.html#ga66aa915a26d698c60ed206818c3e4c9b">Eigen::Quaternionf</a></li>
</ul>
<h1><a class="anchor" id="FixedSizeVectorizable_explanation"></a>
Explanation</h1>
<p>First, "fixed-size" should be clear: an Eigen object has fixed size if its number of rows and its number of columns are fixed at compile-time. So for example <a class="el" href="group__matrixtypedefs.html#ga276bae130c142e906ad8f47d24d11c1c">Matrix3f</a> has fixed size, but <a class="el" href="group__matrixtypedefs.html#ga731599f782380312960376c43450eb48">MatrixXf</a> doesn't (the opposite of fixed-size is dynamic-size).</p>
<p>The array of coefficients of a fixed-size Eigen object is a plain "static array", it is not dynamically allocated. For example, the data behind a <a class="el" href="group__matrixtypedefs.html#ga3a5de8dfef28d29aed525611e15a37e3">Matrix4f</a> is just a "float array[16]".</p>
<p>Fixed-size objects are typically very small, which means that we want to handle them with zero runtime overhead &ndash; both in terms of memory usage and of speed.</p>
<p>Now, vectorization works with 128-bit packets (e.g., SSE, AltiVec, NEON), 256-bit packets (e.g., AVX), or 512-bit packets (e.g., AVX512). Moreover, for performance reasons, these packets are most efficiently read and written if they have the same alignment as the packet size, that is 16 bytes, 32 bytes, and 64 bytes respectively.</p>
<p>So it turns out that the best way that fixed-size Eigen objects can be vectorized, is if their size is a multiple of 16 bytes (or more). Eigen will then request 16-byte alignment (or more) for these objects, and henceforth rely on these objects being aligned to achieve maximal efficiency. </p>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Thu Apr 21 2022 13:07:55 for Eigen by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
